package controller

import (
	"apitestAfterGo/common"
	"apitestAfterGo/domain"
	"apitestAfterGo/dto"
	"apitestAfterGo/service"
	"apitestAfterGo/utils"
	"github.com/kataras/iris/v12/mvc"
)

type TaskReportController struct {
}

func (t *TaskReportController) BeforeActivation(b mvc.BeforeActivation) {
	b.Handle("POST", "/getReportsByRecordId", "GetReportsByRecordId")
}

func (t *TaskReportController) GetReportsByRecordId(dto dto.TaskReportDto) common.Result {
	reports, count := service.TaskReportServiceImpl.GetReportsByRecordId(dto)
	pages := utils.GetPages(count, dto.PageSize)
	page := domain.Page{
		Pages:   pages,
		Total:   count,
		Current: dto.Current,
		Size:    dto.PageSize,
		Records: reports,
	}
	return utils.Success(page, "获取测试报告成功")
}
